package com.wk.search.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * ES中存储的商品对象
 */
@Data
@Document(indexName = "goods",type = "info",shards = 2,replicas = 1)
public class Goods {
	@Id
	private Long skuId;					//商品ID

	@Field(type = FieldType.Keyword,index = false)
	private String pic;					//图片地址 不分词 不搜索

	@Field(type = FieldType.Text,analyzer = "ik_max_word")
	private String title;				//商品标题

	@Field(type = FieldType.Double)
	private Double price;

	@Field(type = FieldType.Long)
	private Long sale; 					//销量

	@Field(type = FieldType.Boolean)
	private Boolean store; 			    //是否有货

	@Field(type = FieldType.Date)
	private Date createTime; 			//新品排序

	@Field(type = FieldType.Long)
	private Long brandId;

	@Field(type = FieldType.Keyword)
	private String brandName;

	@Field(type = FieldType.Long)
	private Long categoryId;

	@Field(type = FieldType.Keyword)
	private String categoryName;

	/*保存当前sku所有需要检索的属性；
	检索属性来源于spu的基本属性中的search_type=1（销售属性都已经拼接在标题中了）
	Nested:嵌套*/
	@Field(type = FieldType.Nested)
	private List<SearchAttr> attrs;  // 搜索属性
}
